using JamesZhao.Engine.Graphics.Effects;
using JamesZhao.Engine.Graphics.Surfaces;
using SlimDX;
using SlimDX.DXGI;

namespace JamesZhao.Engine.Graphics.RenderStages
{
    public abstract class RenderStage
    {
        public ColorSurface FinalColorSurface { get; set; }
        public DepthSurface FinalDepthSurface { get; set; }

        public abstract string Name { get; }

        protected abstract void OnRender(GraphicsDevice device, SwapChain swapChain, VisualsList visualsList,
                                         Camera camera);
        protected virtual void PreRender(GraphicsDevice device, SwapChain swapChain, VisualsList visualsList,
                                         Camera camera) { }
        public void Render(GraphicsDevice device, SwapChain swapChain, VisualsList visualsList, Camera camera)
        {
            BeginEvent("Stage - " + Name);
            PreRender(device, swapChain, visualsList, camera);
            OnRender(device, swapChain, visualsList, camera);
            EndEvent();
        }


        protected void SetGlobalShaderConstants(GpuProgram gpuProgram, Camera camera)
        {
        }

        protected static void BeginEvent(string name)
        {
            Performance.BeginEvent(new Color4(1, 0, 1, 0), name);
        }

        protected static void EndEvent()
        {
            Performance.EndEvent();
        }
    }
}